package com.tgl.router;

import com.tgl.handler.PongHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.server.*;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;
import java.util.Objects;

import static org.springframework.web.reactive.function.server.RequestPredicates.GET;

/**
 * @author tonggl
 * @date 2024/7/22 16:55
 * @description TODO
 */
@Configuration
public class PongRouter {

    @Bean
    public RouterFunction<ServerResponse> msgRoutes(PongHandler pongHandler) {
        return RouterFunctions.route(RequestPredicates.GET("/pong"), new HandlerFunction<ServerResponse>() {
            @Override
            public Mono<ServerResponse> handle(ServerRequest request) {
                return pongHandler.receiveMsg(request.queryParam("parameter").get());
            }
        });
    }

}
